#define _CRT_SECURE_NO_WARNINGS 1
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long

int t, m, n;
string s[55];
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> t;
	while (t--) {
		cin >> n >> m;
		int sum = 0, num = 0;
		for (int i = 1; i <= n; i++) cin >> s[i];
		for (int i = 1; i <= n; i++) {
			if (sum + s[i].size() <= m) {
				sum += s[i].size();
				num++;
			}
			else break;
		}
		cout << num << '\n';
	}
	return 0;
}